#ifndef MSCATTERINGLIDARFORM_H
#define MSCATTERINGLIDARFORM_H

#include <QWidget>
#include <QMutex>
#include <QThread>

#include "loopcomputerandgetnextcomputerdata.h"
#include "lidarclient.h"

// class LoopComputerAndGetComputerData:public QThread
// {
// public:
//     LoopComputerAndGetComputerData(QObject *parent = nullptr)
//     : QThread(parent) {}

//     void SetGuid(const lidar::GUID &guid) { m_guid = guid; }
//     void SetDuration(const int duration) { m_duration = duration; }
//     void SetClient(QSharedPointer<LidarClient> client ) { m_client = client; }
//     void SetMutex(QSharedPointer<QMutex> mutex) {m_mutex = mutex;}

//     void run();
// private:
//     lidar::GUID m_guid;
//     int m_duration;
//     QSharedPointer<LidarClient> m_client;
//     QSharedPointer<QMutex> m_mutex;
//     //QDateTime m_lastTime;
// };


namespace Ui {
class MScatteringLidarForm;
}

class MScatteringLidarForm : public QWidget
{
    Q_OBJECT

public:
    explicit MScatteringLidarForm(QWidget *parent = nullptr);
    ~MScatteringLidarForm();

public slots:
    //lidarClient调用GetPMTState后，对返回值进行处理的槽函数
    void Slot_resGetPMTState(const QSharedPointer<lidar::RuntimeParamsPackage>);
    //lidarClient调用StartAcquire后，对返回值进行处理的槽函数
    void Slot_resStartAcquire(const QSharedPointer<lidar::XError>);
    //lidarClient调用GetNextComputeData后，对返回值进行处理的槽函数
    void Slot_resGetNextComputeData(const QSharedPointer<lidar::ComputedResult>);
    //lidarClient调用GetNextData后，对返回值进行处理的槽函数
    void Slot_resGetNextData(const QSharedPointer<lidar::LidarRawData> );


private:
    Ui::MScatteringLidarForm *ui;
    QSharedPointer<LidarClient> m_client;
    std::shared_ptr<grpc::Channel> m_channel;
    void formInit();
    QSharedPointer<QMutex> m_mutex;
    lidar::GUID m_guid;
    LoopComputerAndGetNextComputerData* m_loopComputerAndGetComputerData;

    //以下为测试函数
    void test_computer();
    void test_getNextComputerData();
    void test_setLaser();
    void test_beginQueryData();
    void test_getNextData();
    void test_moveToAngle();

    //一键登录，开光，采集
    void test_allwork();
signals:
    void Sig_sendLidarClient(QSharedPointer<LidarClient>, QSharedPointer<QMutex>);
    void Sig_startLoopComputerAndGetNextComputerData();
    void Sig_stopLoopComputerAndGetNextComputerData();
};



#endif // MSCATTERINGLIDARFORM_H
